﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;
using Conis.Squirrel;
using System.Data;

/*
 * Author:Conis
 * Date:
 * Description:SQL工厂类
 */

namespace Conis.Squirrel.SqlBuilder.SQLite
{
    public class SqlFactory : BaseSqlFactory
    {
        public SqlFactory(string connectionString) : base(connectionString) { }

        /// <summary>
        /// 获取执行SQL的实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseExecuteSql GetExecuteSql()
        {
            return new ExecuteSql(this.Connection as SQLiteConnection, this.Transaction as SQLiteTransaction);
        }

        /// <summary>
        /// 获取连接对象
        /// </summary>
        /// <returns></returns>
        protected override IDbConnection GetConnection()
        {
            return new SQLiteConnection(this.ConnectionString);
        }

        /// <summary>
        /// 获取条件的实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseCondition GetCondition()
        {
            return new Condition();
        }

        /// <summary>
        /// 获取排序的实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseOrderBy GetOrderBy()
        {
            return new OrderBy();
        }

        /// <summary>
        /// 获取数据库访问的实现类
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="primaryKey"></param>
        /// <returns></returns>
        protected override BaseDataAccess GetDataAccess(string tableName, string primaryKey)
        {
            return new DataAccess(this, tableName, primaryKey);
        }
    }
}
